﻿using System;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using LFloatMath.Math;

namespace IQIGame.Onigao.Logic
{
    public class Skilleffective_ReplaceBuffMaker : SkillEffective
    {
        protected override ISerializeCustomPOD OnExecute(SkillEffectiveData data, Unit target, SkillEffectiveContext context, int effectiveIndex, out SkillEffectiveResponse startResp)
        {
            startResp = null;
            this.Replace(target, ref context);
            return null;
        }

        protected override ISerializeCustomPOD OnActionExecute(SkillEffectiveData data, SkillActionNode action, Unit target, ref SkillEffectiveContext context, int effectiveIndex)
        {
            this.Replace(target, ref context);
            return null;
        }

        private void Replace(Unit rTarget, ref SkillEffectiveContext rContext)
        {
            if (rContext.param is BuffHandler rHandler)
            {
                rHandler.maker = rTarget.GetComponent<BuffComponent>(ETComponentType.BuffComponent);
            }
        }

#if UNITY_EDITOR
        public override string ToString(SkillCustomConfig config)
        {
            return "提换buff的释放者为目标单位";
        }
#endif
    }
}